﻿using System;
using System.Collections.Generic;

namespace MQ.Core.Common
{
    /// <summary>
    /// 分页
    /// </summary>
    public class Pagination
    {
        /// <summary>
        /// 当前页
        /// </summary>
        public int index { set; get; }
        /// <summary>
        /// 每页显示记录数
        /// </summary>
        public int size { set; get; }
        /// <summary>
        /// 排序字段
        /// </summary>
        public string field { set; get; }
        /// <summary>
        /// 排序方式
        /// </summary>
        public string orderBy { set; get; }
        /// <summary>
        /// 总记录数
        /// </summary>
        public int total { set; get; }
        /// <summary>
        /// 总页数
        /// </summary>
        public int pageCount {
            get {
                if (size == 0) return 0;
                return total % size == 0 ? total / size : total / size + 1;
            }
        }
        /// <summary>
        /// 数据
        /// </summary>
        public object data { set; get; }

        public Pagination PageList(object data)
        {
            this.data = data;
            return this;
        }
    }
}
